package com.telecom.weixi.net;

import org.ksoap2.serialization.SoapObject;

import com.telecom.weixi.util.Utils;

import android.os.Handler;

public class AsyncSender extends Thread {
	private static WebServiceEngine wsClient = new WebServiceEngine();

	private ReqParam requset;
	private Handler handler;
	private WebServiceEngine.CallbackRunnable callback;

	public AsyncSender(ReqParam req, Handler handler, WebServiceEngine.CallbackRunnable callback) {
		this.requset = req;
		this.handler = handler;
		this.callback = callback;
	}

	String Tag = "AsyncSender";

	@Override
	public void run() {

		synchronized (wsClient) {
			String soapAction = requset.getActionMethod();
			SoapObject req = requset.getSoapReq();
			Utils.debug("test", "method: " + soapAction);
			RespResult resp = wsClient.doSoapAction(requset.getReqType(), req, WebServiceEngine.NAME_SPACE + soapAction);
			callback.setResponse(resp);
			handler.post(callback);
		}
	}

}
